import { Controller, Post, Inject, Body } from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
import { LogsContent } from '../interface';
import { LoggerHanderService } from '../service/logs.service';
import {FlatLogsHandlerService} from '../service/logsflat.service'
@Controller('/remote')
export class HomeController {

  @Inject()
  ctx: Context

  @Inject()
  loggerHanderService: LoggerHanderService

  @Inject()
  flatLogsHandlerService: FlatLogsHandlerService;

  @Post('/')
  async handLogs(@Body() logsContent: LogsContent): Promise<boolean> {

    await this.flatLogsHandlerService.restoreLog(logsContent);
    return await this.loggerHanderService.restoreLog(logsContent);
  }

}
